import { createRouter, createWebHashHistory } from "vue-router";
import { useAllStore } from "@/store/modules/base";
const routes = [
  {
    path: "/",
    name: "Home",
    meta: {
      title: "心悦冥想管理后台"
    },
    component: () => import("../views/Home.vue"),
    children: [
      {
        path: "/coderCreate",
        name: "coderCreate",
        meta: {
          menu: true,
          title: "代码生成"
        },
        component: () => import("../views/coderCreate/coderCreate.vue")
      },
      {
        path: "/example",
        name: "example",
        meta: {
          menu: true,
          title: "页面示例"
        },
        component: () => import("../views/example/example.vue")
      },
      {
        path: "/img",
        name: "img",
        meta: {
          menu: true,
          title: "页面示例"
        },
        component: () => import("../views/img/img.vue")
      }
    ]
  },
  {
    path: "/login",
    name: "Login",
    meta: {
      title: "登录"
    },
    component: () => import("../views/login/Login.vue")
  }
];
const router = createRouter({
  history: createWebHashHistory(import.meta.env.VITE_APP_NAME),
  routes
});
router.beforeEach(async (to, from) => {
  // const store = useAllStore();
  // to.meta.fromName = from.name;
  // document.title = `${to.meta.title || ""}`;
  // if (to.path === "/login") {
  return true;
  // } else {
  //   return store.token ? true : "/login";
  // }
});
export default router;
